<?php
require_once '../include/common.inc.php';
require_once '../include/cart.class.php';
if (!checkAdmin()) {
   header("LOCATION:index.php");
  exit;
}

getMyParam('cid');
$sql="select * from cus_order where id=$cid";
$query = $db->query($sql);
$order_ary = $db->fetch_array($query);
$order_date=date("Y-m-d",$order_ary["date"]);
$deliveraddress = $order_ary['d_street'] . "<br>" . $order_ary['d_city'] . "<br>" . $order_ary['d_state'] . "<br>" . $order_ary['d_zip'] . "<br>" . $order_ary['d_country'];
$invoiceno=date("Y")."-Web-".$cid;
$order_ary['card_number']=substr($order_ary['card_number'],-4);
/////////////////////////////////////////////////////////get cart information/////////////
$cart_info=new cart;

$cart_info=unserialize($order_ary['cart_info']);
$cart_info_ary = $cart_info->getData();

foreach ($cart_info_ary as $k=>$v) 
{
	if ($v['type'] == 'Courses / Programs') {
		$commission += $v['cost']*$c_r_trainings/100;
	} elseif ($v['productinfo']['is_special'] == 1) {
		$commission += $v['cost']*$c_r_special/100;
	} else {
		$commission += $v['cost']*$c_r_products/100;
	}

	if (isset($v['special_flag']) && $v['special_flag']>0 ) {
		$price_show = "<span style='TEXT-DECORATION: line-through'>" . $v['old_price'] . "</span><br>" . $v['price'];
	} else {
		$price_show = $v['price'];
	}

	$cart_list .= '<tr>
			<td class="en_black_12">'. $v['name'] .'</td>
			<td class="en_black_12">'. $price_show .'</td>
			<td class="en_black_12">'. $v['count'] .'</td>
			<td class="en_black_12">'. $v['cost'] .'</td>
		  </tr>';
}

$totalCost=$cart_info->getTotalCost();
$discount=$cart_info->getDisCount();
$new_total=number_format($totalCost-$discount,2,'.','');
$vat_fee=$cart_info->getAddVat();
$addshippingfee=$cart_info->getAddShippingFee();
$totalCost2=$cart_info->getTotalCost2();

$cart_list .= '<tr>
			<td class="en_black_12" colspan="4" align="right">
				<strong>Sub Total:</strong> DKK'.$totalCost.'<br/> 
				<strong>Discount:</strong> DKK'.$discount.'<br/>
				<strong>New Sub Total:</strong> DKK'.$new_total.'<br/> 
				<strong>VAT:</strong> DKK'.$vat_fee.'<br/> 
				<strong>Shipping Fee:</strong> DKK'.$addshippingfee.'<br/> 
				<strong>Total:</strong> '.$totalCost2.'</td>				
		  </tr>';
////////////////////////////////////////////////
//Customer Details
$sql="select * from cus_members where id=".$order_ary['user_id'];
$query = $db->query($sql);
$customer_ary = $db->fetch_array($query);
$username = empty($customer_ary['lastname']) ? $customer_ary['firstname'] : $customer_ary['firstname'] . ' ' . $customer_ary['lastname'];
$user_address = $customer_ary['street'] . "<br>" . $customer_ary['city'] . "<br>" . $customer_ary['state'] . "<br>" . $customer_ary['zip'] . "<br>" . $customer_ary['country'];
$email = $customer_ary['email'];
//Promoter Details
$sql="select * from promoter_info where id=".$order_ary['promoter_id'];
$query = $db->query($sql);
$promoter_ary = $db->fetch_array($query);
$promoter_name = empty($promoter_ary['lastname']) ? $promoter_ary['firstname'] : $promoter_ary['firstname'] . ' ' . $promoter_ary['lastname'];
$promoter_id=$promoter_ary['id'];
//Other Info
$order_ary['card_type']=$CARD_TYPE_ARY[$order_ary['card_type']];

$btn_send.= "<script language=\"JavaScript\" type=\"text/JavaScript\" src=\"../css/admin.js\"></script>";
$btn_send .="<object id=\"WebBrowser\" CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\" height=\"0\" width=\"0\"></object>";
$btn_send.="<style type=\"text/css\" media=\"print\">.noprint{display:none;}</style><div class='noprint'>
			<input name=\"print\" type=\"button\" id=\"btnPrint\" value=\" Print \"  style=\" COLOR: #000000; BACKGROUND-COLOR: #FDD970; border:1px solid; font-family: 'verdana'; font-size:11 px; border-color:  #FFFFFF #CC6600 #CC6600 #FFFFFF\"\" onclick=\"PrintClick();\"/>&nbsp;&nbsp;&nbsp;&nbsp;
			<input name=\"preview\" type=\"button\" id=\"btnPreview\" value=\" Preview \"  style=\" COLOR: #000000; BACKGROUND-COLOR: #FDD970; border:1px solid; font-family: 'verdana'; font-size:11 px; border-color:  #FFFFFF #CC6600 #CC6600 #FFFFFF\" onclick=\"PrintPreview();\"/></div>";

//LOGO IMAGE
$imgLogo = "<img src='../images/awlogo.jpg' border=0/>";
//TODAY
$today=date("M d,Y");

include 'c_print_invoice_to_members_da.php';

echo $content;
?>
